package liumengbaio.lolzhangyoubao.Activity.Activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;

import java.util.ArrayList;
import java.util.List;

import liumengbaio.lolzhangyoubao.Activity.Adapter.MoreEquipAdapter;
import liumengbaio.lolzhangyoubao.Activity.Fragment.FragmentEqipMove;
import liumengbaio.lolzhangyoubao.Activity.Fragment.FragmentEqipRemove;
import liumengbaio.lolzhangyoubao.Activity.Fragment.FragmentEqipTool;
import liumengbaio.lolzhangyoubao.Activity.Fragment.FragmentEquipAttack;
import liumengbaio.lolzhangyoubao.Activity.Fragment.FragmentEquipDefense;
import liumengbaio.lolzhangyoubao.Activity.Fragment.FragmentEquipMagic;
import liumengbaio.lolzhangyoubao.R;

/**
 * 装备查询界面
 * Created by lanouhn on 16/9/19.
 */
public class MoreEquipActivity extends AppCompatActivity {

    private ImageView back;
    private List<String> tabName;
    private List<Fragment> fragments;
    private TabLayout mTabLayout;
    private ViewPager mViewPager;
    private MoreEquipAdapter adapter;
    private FragmentEqipMove move;
    private FragmentEqipTool tool;
    private FragmentEquipMagic magic;
    private FragmentEqipRemove remove;
    private FragmentEquipAttack attack;
    private FragmentEquipDefense defense;

    @Override

    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.more_equip);
        initView();
        initData();
        initEvent();
    }

    private void initView() {
        mTabLayout = (TabLayout) findViewById(R.id.more_equip_tab);
        mViewPager = (ViewPager) findViewById(R.id.more_equip_viewPager);
        back = (ImageView) findViewById(R.id.more_recreation_back);

        tabName = new ArrayList<>();
        fragments = new ArrayList<>();

        move = new FragmentEqipMove();
        tool = new FragmentEqipTool();
        magic = new FragmentEquipMagic();
        remove = new FragmentEqipRemove();
        attack = new FragmentEquipAttack();
        defense = new FragmentEquipDefense();
    }

    private void initData() {
        tabName.add("防御");
        tabName.add("魔法");
        tabName.add("攻击");
        tabName.add("移动");
        tabName.add("工具");
        tabName.add("已移除");

        fragments.add(defense);
        fragments.add(magic);
        fragments.add(attack);
        fragments.add(move);
        fragments.add(tool);
        fragments.add(remove);


        adapter = new MoreEquipAdapter(getSupportFragmentManager(), tabName, fragments);
        mViewPager.setAdapter(adapter);
        mTabLayout.setupWithViewPager(mViewPager);
    }

    private void initEvent() {
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }
}
